import tools as Tools
import data as Data

screen = Tools.screen
Actor = Tools.Actor
Animation = Tools.Animation

class User:
    def __init__(self):
        import tkinter
        import ttkbootstrap as ttk
        self.Root = tkinter.Tk()
        self.Root.geometry('500x520')
        self.Lable1 = ttk.Label(self.Root,text='A')
        self.Entry1 = ttk.Entry(self.Root)
        self.Lable2 = ttk.Label(self.Root,text='B')
        self.Entry2 = ttk.Entry(self.Root)
        self.Lable3 = ttk.Label(self.Root,text='C')
        self.Entry3 = ttk.Entry(self.Root)
        self.Lable4 = ttk.Label(self.Root,text='D')
        self.Entry4 = ttk.Entry(self.Root)
        self.Button = ttk.Button(self.Root,text='提交',command=self.Judgment)
        self.Tip = ttk.Label(self.Root, text=' ')
    def TryThisButtonCommand(self):
        self.Lable1.pack(); self.Entry1.pack()
        self.Lable2.pack(); self.Entry2.pack()
        self.Lable3.pack(); self.Entry3.pack()
        self.Lable4.pack(); self.Entry4.pack()
        self.Button.pack(); self.Tip.pack()
        self.Root.mainloop()
    def Judgment(self):
        posA = self.Entry1.get()
        posB = self.Entry2.get()
        posC = self.Entry3.get()
        posD = self.Entry4.get()
        if posA == '(5,7)' and posB == '(4,4)' and posC == '(0,2)' and posD == '(8,0)':
            Tools.Debug(1,'回答正确')
            self.Tip.configure(text='很好，接着往下去看看吧.',foreground='green')
        else: 
            Tools.Debug(1,'回答错误')
            self.Tip.configure(text='也许你可以注意下格式（包括请使用半角符号）',foreground='red')

class Main:
    def __init__(self):
        Tools.Debug(3,'Part8')
    def Enter(self):
        self.Pic3 = Actor('pic3',[Data.WIDTH-300,Data.HEIGHT+150])
        self.TryThisButton = Actor('try_this',[Tools.CentralX(),Data.HEIGHT+150])
        Animation(self.TryThisButton,'accel_decel',1,None,pos=[300,Tools.CentralY()])
        Animation(self.Pic3,'accel_decel',1,None,y=Tools.CentralY()+50)
    def Update(self):
        screen.fill((0,0,0))
        self.Pic3.draw()
        self.TryThisButton.draw()
        screen.draw.text("在直角坐标系中，对于平面上的任意一点，都有唯一的一个有序数对（即点的坐标）与它对应.",(100,100),"osans4.ttf")
        screen.draw.text("例如，某点在平面直角坐标系中的横坐标为x，纵坐标为y，则其坐标可记作(x,y).",(100,150),"osans4.ttf")
        screen.draw.text("依葫芦画瓢，让我们试试看.",(100,200),"osans4.ttf")
    def Touch(self,pos):
        if self.TryThisButton.collidepoint(pos):
            User().TryThisButtonCommand()